package com.CI.ViewAllBook.Business
{
	import com.CI.ViewAllBook.VO.BookPublished;
	import com.adobe.cairngorm.business.Responder;
	
	import mx.rpc.AsyncToken;
	import mx.rpc.http.HTTPService;
	
	public class ViewDelegate
	{
		protected var responder : Responder;
		
		public function ViewDelegate(responder : Responder)
		{
			this.responder = responder;
		}
		
		public function sendObject(obj : Object) : void
		{
			var params : Object = new Object();
			var service : HTTPService;
			var token : AsyncToken;
			var responder : mx.rpc.Responder;
			
			if(obj is BookPublished)
			{
				params.action = 'ViewAllBookPublished';	
				
				service = ServiceLocator.getInstance().getHTTPService("ViewAllBookPublished");
		    	
		    	token = service.send(params);
				responder = new mx.rpc.Responder(Add_onResult, Add_onFault);
				token.addResponder(responder);
			}
			else
			{
				params.action = 'ViewAllEBook';
				
				service = ServiceLocator.getInstance().getHTTPService("ViewAllEBook");
		    	
		    	token = service.send(params);
				responder = new mx.rpc.Responder(Add_onResult, Add_onFault);
				token.addResponder(responder);
			}
		}
		
		protected function Add_onResult(event:ResultEvent) : void
		{
			
		}
		
		protected function Add_onFault(event:FaultEvent) : void
		{
		
		}
	}
}